Skip to content

[WRONG BRANCH] fix(service): bind lifecycle to CODEX_SQLITE_HOME - #263

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-split-sqlite-history-issue
Draft

[WRONG BRANCH] fix(service): bind lifecycle to CODEX_SQLITE_HOME#263
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-split-sqlite-history-issue

Conversation

@luvs01

@luvs01 luvs01 commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Service launchers began baking an effective CODEX_SQLITE_HOME into artifacts but the install-state did not record it, allowing later ocx service stop/uninstall/repair runs from shells with different or absent CODEX_SQLITE_HOME to target the wrong SQLite database.

Description

  • Add an optional codexSqliteHome field to ServiceInstallState and accept it in parseServiceInstallState with validation to reject empty strings. (imported resolveCodexSqliteHome)
  • Persist the resolved SQLite home during install via writeServiceInstallState(...) so the install-state reflects the actual history target used by the baked service artifacts.
  • Strengthen assertServiceEnvironmentMatchesInstall() to compare the recorded codexSqliteHome to the current resolved SQLite home and fail-closed if they differ, preventing lifecycle operations from mutating a different DB.
  • Add unit test coverage and test scaffolding changes in tests/service.test.ts to validate rejecting lifecycle operations when the recorded SQLite home does not match the current environment and to restore CODEX_SQLITE_HOME env in cleanup.

Testing

  • Ran typecheck with bun x tsc --noEmit / bun run typecheck and it succeeded.
  • Ran the privacy scan with bun run privacy:scan and it passed.
  • Ran the focused unit tests bun test tests/service.test.ts and the new regression (mismatched SQLite home) passed.
  • Ran the repository test harness bun run test / bun scripts/test.ts; the full run produced many passing tests and exercised the service suites, while a pre-existing unrelated assertion in the service diagnostics surface was observed separately during full-suite runs (the targeted service tests passed).

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@luvs01, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4b62992a-c56b-49a3-a28c-c8b48983360d

📥 Commits

Reviewing files that changed from the base of the PR and between 1193075 and 016a93e.

📒 Files selected for processing (2)
  • src/service.ts
  • tests/service.test.ts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 13, 2026
@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 016a93e725

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/service.ts
version: 2,
codexHome: currentCodexHome(),
opencodexHome: currentOpenCodexHome(),
codexSqliteHome: resolveCodexSqliteHome({ codexHome: currentCodexHome() }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind relative SQLite homes to a stable service directory

When config.toml contains a relative sqlite_home, this records the path resolved against the installer's process.cwd(), but the generated plist, systemd unit, and Windows launcher do not preserve that working directory. The supervised process can therefore resolve the same configuration to another database, while a later command run from the installation directory passes this ownership check and restores the recorded—but wrong—database. Preserve a stable working directory in the service artifact or otherwise ensure the recorded path is exactly the one the child uses, with regression coverage for relative sqlite_home.

AGENTS.md reference: src/AGENTS.md:L10-L10

Useful? React with 👍 / 👎.

Comment thread src/service.ts
Comment on lines +322 to +323
if (state.codexSqliteHome !== undefined) {
const actualCodexSqliteHome = resolveCodexSqliteHome({ codexHome: actualCodexHome });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat SQLite resolution failures as ownership failures

When config.toml is unreadable or has an invalid sqlite_home, this resolver throws a plain Error before the service manager is contacted. The ocx stop path in src/cli/index.ts only sets ownershipBlocked for ServiceOwnershipError, so it treats this as an ordinary stop failure and continues into native Codex restoration and Grok cleanup while the installed service remains registered and may still be running. Convert this indeterminate resolution into the fail-closed ownership representation so callers skip shared teardown.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions github-actions Bot changed the title fix(service): bind lifecycle to CODEX_SQLITE_HOME [WRONG BRANCH] fix(service): bind lifecycle to CODEX_SQLITE_HOME Aug 13, 2026
@github-actions
github-actions Bot marked this pull request as draft August 13, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant